$(function(){
	$('#loged_mingxi').click(function(){ //点击查询明细包含明细页面
		var u="UserServlet?instatus=selectmingxi";
		$.ajax({
			type:'post',
			url:u,		
			datatype:'json',
			success:function(msg){
				if(msg==1){
					$('#div_jubu_n').load('Mingxi.jsp');
				}
			},
			error:function(){
				alert("错误信息");
			}
	})
	})
	$('#loged_status').click(function(){  //点击查询状态，包含查询状态页面
		var u="UserServlet?instatus=selectstatus";
		$.ajax({
			type:'post',
			url:u,		
			datatype:'json',
			success:function(msg){
				if(msg==1){
					$('#div_jubu_n').load('Selectstatus.jsp');
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	})
	$('#loged_user').click(function(){  //点击查询用户信息，包含用户信息页面
		var u="UserServlet?instatus=selectuser";
		$.ajax({
			type:'post',
			url:u,		
			datatype:'json',
			success:function(msg){
				if(msg==1){
					$('#div_jubu_n').load('Selectuser.jsp');
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	})
	$('#submit_log').click(function(){  //登陆功能
		var u="UserServlet?instatus=login";
		$.ajax({
			type:"post",
			url:u,
			data:$('#loginform').serialize(),
			dataType:'json',
			success:function(msg){
				if(msg==0){
					$('#div_log_name').empty();
					$('#div_log_pass').empty();
					$('#div_log_name').html("<font color='red' size='1'>*用户不存在</font>");
				}else if(msg==1||msg==3){
					$('#div_log_name').empty();
					$('#div_log_pass').empty();
					$('#div_log_pass').html("<font color='red' size='1'>*密码输入错误</font>");
				}else if(msg==2||msg==4){
					window.location.href="Loged.jsp";
				}
			},
			error:function(){
				alert("error错误信息");
			}
		})
	});
	//注册功能的实现
	$('#a_register').click(function(){
		 $("#bg").css({
	            display: "block", height: $(document).height()
	        });
		 var $zhaohui=$('#register_one');
		$zhaohui.css({
			left:200+"px",
			top:40+"px",
			display:"block",
		});
	});
	$('#register1_cancel').click(function(){
		$('#bg,#register_one').css("display","none");
	});
	$('#register1_next').click(function(){  //注册第一步
		var u="UserServlet?instatus=register";
		$.ajax({
			type:"post",
			url:u,
			data:$('#register_form').serialize(),
			dataType:'json',
			success:function(msg){
				if(msg==-1){
					$('#div_register_cardid').empty();
					$('#div_register_userid').empty();
					$('#div_register_pass').empty();
					$('#div_register_cardid').html("<font size='1' color='red'>*您的卡号已开通网银</font>");
				}else if(msg==0){
					$('#div_register_cardid').empty();
					$('#div_register_userid').empty();
					$('#div_register_pass').empty();
					$('#div_register_cardid').html("<font size='1' color='red'>*您输入的卡号不存在</font>");
				}else if(msg==1){
					$('#div_register_cardid').empty();
					$('#div_register_userid').empty();
					$('#div_register_pass').empty();
					$('#div_register_userid').html("<font size='1' color='red'>*身份证号和卡号不匹配</font>");
				}else if(msg==2){
					$('#div_register_cardid').empty();
					$('#div_register_userid').empty();
					$('#div_register_pass').empty();
					$('#div_register_pass').html("<font size='1' color='red'>*取款密码输入错误</font>");
				}else if(msg==3){
					$('#register_one').css("display","none");
					$('#register_two').css({
						left:200+"px",
						top:40+"px",
						display:"block",
					});
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	});
	$('#register2_before').click(function(){
		$('#register_two').css("display","none");
		$('#register_one').css("display","block");
	});
	$('#register2_cancel').click(function(){
		$('#bg,#register_two').css("display","none");
	});
	$('#register2_next').click(function(){  //注册第二步
		var u="UserServlet?instatus=register_next";
		$.ajax({
			type:"post",
			url:u,
			data:$('#register_next_form').serialize(),
			dataType:'json',
			success:function(msg){
				if(msg==0){
					$('#div_register_next_pass').empty();
					$('#div_register_next_name').empty();
					$('#div_register_next_pass').html("<font size='1' color='red'>*两次密码输入不一致</font>");
				}else if(msg==1){
					$('#div_register_next_pass').empty();
					$('#div_register_next_name').empty();
					$('#register_two').css("display","none");
					$('#register_three').css({
						left:200+"px",
						top:40+"px",
						display:"block",
					});
				}else if(msg==2){
					$('#div_register_next_pass').empty();
					$('#div_register_next_name').empty();
					$('#div_register_next_name').html("<font size='1' color='red'>*用户名不可为空</font>");
				}else if(msg==3){
					$('#div_register_next_pass').empty();
					$('#div_register_next_name').empty();
					$('#div_register_next_pass').html("<font size='1' color='red'>*密码不可为空</font>");
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	});
	$('#register_three_close').click(function(){
		$('#bg,#register_three').css("display","none");
	});
	$('#register_three_login').click(function(){
		window.location.href="Loged.jsp";
	});
	$('#changepass').click(function(){  //修改密码
		var u="UserServlet?instatus=changepass";
		$.ajax({
			type:"post",
			url:u,
			data:$('#changepass_form').serialize(),
			dataType:'json',
			success:function(msg){
				if(msg==0){
					$('#div_changepass').empty();
					$('#div_changepass_new').empty();
					$('#div_changepass_old').empty();
					$('#div_changepass_old').html("<font size='1' color='red'>*原始密码输入错误</font>");
				}else if(msg==1){
					$('#div_changepass').empty();
					$('#div_changepass_new').empty();
					$('#div_changepass_old').empty();
					$('#div_changepass_new').html("<font size='1' color='red'>*两次密码输入不一致</font>");
				}else if(msg==2){
					$('#div_changepass').empty();
					$('#div_changepass_new').empty();
					$('#div_changepass_old').empty();
					$('#div_changepass').html("<font size='1' color='red'>*修改成功</font>");
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	})
	$('#zhuanzhang').click(function(){  //转账
		var u="UserServlet?instatus=zhuanzhang";
		$.ajax({
			type:"post",
			url:u,
			data:$('#zhuanzhang_form').serialize(),
			dataType:'json',
			success:function(msg){
				if(msg==0){
					$('#div_zhuanzhang').empty();
					$('#div_zhuanzhang_cardid').empty();
					$('#div_zhuanzhang_balance').empty();
					$('#div_zhuanzhang_cardid').html("<font size='1' color='red'>*您要转账的卡号不存在</font>");
				}else if(msg==1){
					$('#div_zhuanzhang').empty();
					$('#div_zhuanzhang_cardid').empty();
					$('#div_zhuanzhang_balance').empty();
					$('#div_zhuanzhang_cardid').html("<font size='1' color='red'>*对方卡号已冻结，无法完成转账</font>");
				}else if(msg==2){
					$('#div_zhuanzhang').empty();
					$('#div_zhuanzhang_cardid').empty();
					$('#div_zhuanzhang_balance').empty();
					$('#div_zhuanzhang_balance').html("<font size='1' color='red'>*您卡中的余额不足</font>");
				}else if(msg==3){
					$('#div_zhuanzhang').empty();
					$('#div_zhuanzhang_cardid').empty();
					$('#div_zhuanzhang_balance').empty();
					$('#div_zhuanzhang').html("<font size='1' color='red'>*转账成功</font>");
				}else if(msg==4){
					$('#div_zhuanzhang').empty();
					$('#div_zhuanzhang_cardid').empty();
					$('#div_zhuanzhang_balance').empty();
					$('#div_zhuanzhang_cardid').html("<font size='1' color='red'>*不可以向本卡转账</font>");
				}
			},
			error:function(){
				alert("错误信息");
			}
		})
	})
});